package com.capgemini.simpleappblanche.domain.security;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import org.springframework.security.core.GrantedAuthority;

@SuppressWarnings("serial")
@Getter
@Setter
@ToString(of={"id","name"})
@EqualsAndHashCode(of={"id"})
@Entity
@Table(name = "PERMISSION")
public class Permission implements GrantedAuthority{
	
	// Technical id
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ID")
	private Long id;
	
	@Column( name = "NAME" , nullable = false)
	private String name;

	/**
	 * {@inheritDoc}
	* @see org.springframework.security.core.GrantedAuthority#getAuthority()
	*/
	@Transient
    public String getAuthority() {
        return name;
    }
}
